package goodenglish.interfaces.videoplay;

import goodenglish.domain.service.media.PlaySubt;
import goodenglish.infrastructure.Config;

public class PlayRegion {
	// 字幕区间开始时间
	private long stime = 0;
	// 播放区间结束时间
	private long etime = 0;
	// 已经重播次数
	private int replayNum = 0;
	// 是否已经学习字幕
	private boolean studyed = false;
	private int studytime = 0;
	// 是否已经手工取消学习
	public static boolean manCanceled = false;
	private SentenceForPlay sentenceForPlay;

	public PlayRegion(final PlaySubt playSubt, final int subtIndex, final PlayRegion prePlayRegion) {
		manCanceled = false;
		sentenceForPlay = playSubt.getSubtSentencesForPlay(subtIndex, Config.PLAYLISTENER_STEP);
		this.setStudytime(Config.PLAYLISTENER_STUDYTIME * sentenceForPlay.subtWordCounts);
		// 设置开始时间为上一个字幕的结束时间
		if (null != prePlayRegion && prePlayRegion.getEtime() > 0) {
			this.setStime(prePlayRegion.getEtime());
		}
		// 设置结束时间为区间结束时间
		this.setEtime(sentenceForPlay.lastEtime);
	}

	public long getStime() {
		return stime;
	}

	public void setStime(long regionStime) {
		this.stime = regionStime;
	}

	public long getEtime() {
		return etime;
	}

	public void setEtime(long regionEtime) {
		this.etime = regionEtime;
	}

	public int getReplayNum() {
		return replayNum;
	}

	public boolean isStudyed() {
		return studyed;
	}

	public void setStudyed(boolean studyed) {
		this.studyed = studyed;
	}

	public int getStudytime() {
		return studytime;
	}

	public void setStudytime(int studytime) {
		this.studytime = studytime;
	}

	public boolean over(int curTime) {
		if (curTime > this.etime) {
			return true;
		} else {
			return false;
		}

	}

	public void addPlayNum() {
		this.replayNum++;
	}

	public SentenceForPlay getSentenceForPlay() {
		return sentenceForPlay;
	}
}
